项目背景概述

青少年怀孕对母亲和儿童都是高风险,它们更有可能导致早产,低出生体重,分娩病危症和死亡。许多青春期怀孕是意料之外的,但年轻女孩可能会继续怀孕,放弃接受教育和就业的机会,或寻求不安全的堕胎方法。生殖健康是与生殖系统及其功能和过程有关的身心健康状态,可以通过怀孕和分娩期间的教育和服务,安全有效的避孕措施以及性传播疾病的预防和治疗来提供支持,低收入和中等收入国家中,怀孕和分娩的病发症是导致育龄妇女和致残的主要原因。

全球青少年怀孕现状:

对一些青少年而言,怀孕和分娩是有计划、受期待的结果,但对许多人不是这样。青少年怀孕更常见于贫穷、没有受过教育的农村社区。在一些国家,未婚怀孕并不鲜见。相比之下,一些少女可能面临结婚的社会压力,而且一旦结婚,就有必须生产的压力。低收入和中等收入国家有30%以上的少女在18岁以前结婚,约有14%结婚时未满15岁。一些少女不知道如何避孕,性教育在许多国家都很缺乏。她们可能感到太难以或羞于寻求避孕服务;避孕药可能过于昂贵或者没有广泛或以合法渠道提供。即便在避孕药广泛提供的情况下,性活跃的青春期少女使用它们的几率也比成年人低。少女可能无法拒绝非自愿的性行为或抵制强迫的性行为,这些通常都是无保护的性行为。针对全球青少年怀孕的社会现状,该项目主要利用了全球青少年怀孕率,孕妇死亡率,各国人均GDP的数据来分析这三项指标的关系,并引申出青少年怀孕率所映射出的社会问题。

In [56]:
import numpy as np
import pandas as pd
import csv,os
In [57]:
from pyecharts.charts import Bar,Tab,Line,Map,Timeline,Grid,Scatter
from pyecharts import options as opts 
import pandas as pd 
In [59]:
dfa = pd.read_csv('Adolescent_fertility_rate.csv',encoding = 'utf8')
In [60]:
dfa
Out[60]:
CountryName CountryCode 2010 2011 2012 2013 2014 2015 2016 2017
0 Aruba ABW 30.652000 29.582000 28.512000 27.344400 26.176800 25.009200 23.841600 22.674000
1 Afghanistan AFG 113.715000 107.256000 100.797000 94.429000 88.061000 81.693000 75.325000 68.957000
2 Angola AGO 172.931600 170.165800 167.400000 164.025200 160.650400 157.275600 153.900800 150.526000
3 Albania ALB 19.820800 20.275400 20.730000 20.512400 20.294800 20.077200 19.859600 19.642000
4 Arab World ARB 49.966897 49.866891 49.790826 49.344963 48.853665 48.279737 47.505489 46.688851
5 United Arab Emirates ARE 22.020800 19.395400 16.770000 14.725200 12.680400 10.635600 8.590800 6.546000
6 Argentina ARG 63.315400 63.441200 63.567000 63.410000 63.253000 63.096000 62.939000 62.782000
7 Armenia ARM 26.019200 25.430600 24.842000 24.171600 23.501200 22.830800 22.160400 21.490000
8 Antigua and Barbuda ATG 48.664000 47.832000 47.000000 46.156400 45.312800 44.469200 43.625600 42.782000
9 Australia AUS 14.221200 13.261600 12.302000 12.184600 12.067200 11.949800 11.832400 11.715000
10 Austria AUT 9.529200 8.996600 8.464000 8.239200 8.014400 7.789600 7.564800 7.340000
11 Azerbaijan AZE 44.938000 47.089000 49.240000 50.559600 51.879200 53.198800 54.518400 55.838000
12 Burundi BDI 62.485200 61.587600 60.690000 59.670000 58.650000 57.630000 56.610000 55.590000
13 Belgium BEL 7.629400 6.829200 6.029000 5.753400 5.477800 5.202200 4.926600 4.651000
14 Benin BEN 101.290600 98.827800 96.365000 94.311200 92.257400 90.203600 88.149800 86.096000
15 Burkina Faso BFA 121.105200 118.256600 115.408000 113.192200 110.976400 108.760600 106.544800 104.329000
16 Bangladesh BGD 90.803400 89.704200 88.605000 87.476400 86.347800 85.219200 84.090600 82.962000
17 Bulgaria BGR 44.736800 44.246400 43.756000 42.976800 42.197600 41.418400 40.639200 39.860000
18 Bahrain BHR 14.310600 14.151800 13.993000 13.868000 13.743000 13.618000 13.493000 13.368000
19 Bahamas, The BHS 35.463800 34.130400 32.797000 32.237800 31.678600 31.119400 30.560200 30.001000
20 Bosnia and Herzegovina BIH 13.710200 12.883600 12.057000 11.574000 11.091000 10.608000 10.125000 9.642000
21 Belarus BLR 21.749800 21.561400 21.373000 19.999800 18.626600 17.253400 15.880200 14.507000
22 Belize BLZ 75.069800 73.874400 72.679000 71.840600 71.002200 70.163800 69.325400 68.487000
23 Bolivia BOL 76.503800 74.696400 72.889000 71.291200 69.693400 68.095600 66.497800 64.900000
24 Brazil BRA 66.892600 65.472800 64.053000 63.064600 62.076200 61.087800 60.099400 59.111000
25 Barbados BRB 44.557400 43.633200 42.709000 40.877200 39.045400 37.213600 35.381800 33.550000
26 Brunei Darussalam BRN 15.887400 15.164200 14.441000 13.607200 12.773400 11.939600 11.105800 10.272000
27 Bhutan BTN 35.951000 31.970000 27.989000 26.428000 24.867000 23.306000 21.745000 20.184000
28 Botswana BWA 48.354000 48.252000 48.150000 47.732200 47.314400 46.896600 46.478800 46.061000
29 Central African Republic CAF 140.637000 139.551000 138.465000 136.586800 134.708600 132.830400 130.952200 129.074000
... ... ... ... ... ... ... ... ... ... ...
210 Thailand THA 47.913800 49.738400 51.563000 50.232000 48.901000 47.570000 46.239000 44.908000
211 Tajikistan TJK 48.097600 49.262800 50.428000 51.757600 53.087200 54.416800 55.746400 57.076000
212 Turkmenistan TKM 24.732200 25.593600 26.455000 26.047600 25.640200 25.232800 24.825400 24.418000
213 Latin America & the Caribbean (IDA & IBRD coun... TLA 70.832502 69.683648 68.531037 67.511428 66.491085 65.468468 64.413533 63.367187
214 Timor-Leste TLS 44.675800 41.763400 38.851000 37.837800 36.824600 35.811400 34.798200 33.785000
215 Middle East & North Africa (IDA & IBRD countries) TMN 42.491177 43.246737 44.021652 44.116300 44.141192 44.079703 43.940974 43.754576
216 Tonga TON 17.555200 17.078600 16.602000 16.214000 15.826000 15.438000 15.050000 14.662000
217 South Asia (IDA & IBRD) TSA 43.310453 40.659584 38.007895 35.571502 33.114499 30.634980 28.117495 25.584972
218 Sub-Saharan Africa (IDA & IBRD countries) TSS 115.176701 113.552414 111.908141 110.049607 108.206224 106.385944 104.575840 102.788585
219 Trinidad and Tobago TTO 36.118200 35.461600 34.805000 33.862000 32.919000 31.976000 31.033000 30.090000
220 Tunisia TUN 7.126800 7.358400 7.590000 7.640200 7.690400 7.740600 7.790800 7.841000
221 Turkey TUR 34.151400 32.697200 31.243000 30.306200 29.369400 28.432600 27.495800 26.559000
222 Tanzania TZA 127.276000 125.218000 123.160000 122.205000 121.250000 120.295000 119.340000 118.385000
223 Uganda UGA 139.426400 135.657200 131.888000 129.277600 126.667200 124.056800 121.446400 118.836000
224 Ukraine UKR 28.936200 28.444600 27.953000 27.104600 26.256200 25.407800 24.559400 23.711000
225 Upper middle income UMC 31.068812 31.505131 31.710946 31.584812 31.386329 31.196884 30.976814 30.725634
226 Uruguay URY 60.833000 60.743000 60.653000 60.267800 59.882600 59.497400 59.112200 58.727000
227 United States USA 32.594600 30.265800 27.937000 26.321600 24.706200 23.090800 21.475400 19.860000
228 Uzbekistan UZB 21.516800 22.653400 23.790000 23.790000 23.790000 23.790000 23.790000 23.790000
229 St. Vincent and the Grenadines VCT 56.276000 55.392000 54.508000 53.410400 52.312800 51.215200 50.117600 49.020000
230 Venezuela, RB VEN 88.651600 88.235800 87.820000 87.323400 86.826800 86.330200 85.833600 85.337000
231 Virgin Islands (U.S.) VIR 47.282200 46.514600 45.747000 42.375000 39.003000 35.631000 32.259000 28.887000
232 Vietnam VNM 33.955000 35.008000 36.061000 35.034600 34.008200 32.981800 31.955400 30.929000
233 Vanuatu VUT 53.594800 53.069400 52.544000 51.922600 51.301200 50.679800 50.058400 49.437000
234 World WLD 47.806621 47.324775 46.704880 45.916746 45.088384 44.257378 43.361764 42.455699
235 Samoa WSM 29.620200 28.935600 28.251000 27.378000 26.505000 25.632000 24.759000 23.886000
236 Yemen, Rep. YEM 71.243200 69.457600 67.672000 66.208000 64.744000 63.280000 61.816000 60.352000
237 South Africa ZAF 70.088800 71.032400 71.976000 71.162400 70.348800 69.535200 68.721600 67.908000
238 Zambia ZMB 141.601200 139.148600 136.696000 133.379200 130.062400 126.745600 123.428800 120.112000
239 Zimbabwe ZWE 109.742200 109.292600 108.843000 104.301400 99.759800 95.218200 90.676600 86.135000

240 rows × 10 columns

In [61]:
dfa1 =dfa.dropna(axis=0,how='any') 
dfa1
Out[61]:
CountryName CountryCode 2010 2011 2012 2013 2014 2015 2016 2017
0 Aruba ABW 30.652000 29.582000 28.512000 27.344400 26.176800 25.009200 23.841600 22.674000
1 Afghanistan AFG 113.715000 107.256000 100.797000 94.429000 88.061000 81.693000 75.325000 68.957000
2 Angola AGO 172.931600 170.165800 167.400000 164.025200 160.650400 157.275600 153.900800 150.526000
3 Albania ALB 19.820800 20.275400 20.730000 20.512400 20.294800 20.077200 19.859600 19.642000
4 Arab World ARB 49.966897 49.866891 49.790826 49.344963 48.853665 48.279737 47.505489 46.688851
5 United Arab Emirates ARE 22.020800 19.395400 16.770000 14.725200 12.680400 10.635600 8.590800 6.546000
6 Argentina ARG 63.315400 63.441200 63.567000 63.410000 63.253000 63.096000 62.939000 62.782000
7 Armenia ARM 26.019200 25.430600 24.842000 24.171600 23.501200 22.830800 22.160400 21.490000
8 Antigua and Barbuda ATG 48.664000 47.832000 47.000000 46.156400 45.312800 44.469200 43.625600 42.782000
9 Australia AUS 14.221200 13.261600 12.302000 12.184600 12.067200 11.949800 11.832400 11.715000
10 Austria AUT 9.529200 8.996600 8.464000 8.239200 8.014400 7.789600 7.564800 7.340000
11 Azerbaijan AZE 44.938000 47.089000 49.240000 50.559600 51.879200 53.198800 54.518400 55.838000
12 Burundi BDI 62.485200 61.587600 60.690000 59.670000 58.650000 57.630000 56.610000 55.590000
13 Belgium BEL 7.629400 6.829200 6.029000 5.753400 5.477800 5.202200 4.926600 4.651000
14 Benin BEN 101.290600 98.827800 96.365000 94.311200 92.257400 90.203600 88.149800 86.096000
15 Burkina Faso BFA 121.105200 118.256600 115.408000 113.192200 110.976400 108.760600 106.544800 104.329000
16 Bangladesh BGD 90.803400 89.704200 88.605000 87.476400 86.347800 85.219200 84.090600 82.962000
17 Bulgaria BGR 44.736800 44.246400 43.756000 42.976800 42.197600 41.418400 40.639200 39.860000
18 Bahrain BHR 14.310600 14.151800 13.993000 13.868000 13.743000 13.618000 13.493000 13.368000
19 Bahamas, The BHS 35.463800 34.130400 32.797000 32.237800 31.678600 31.119400 30.560200 30.001000
20 Bosnia and Herzegovina BIH 13.710200 12.883600 12.057000 11.574000 11.091000 10.608000 10.125000 9.642000
21 Belarus BLR 21.749800 21.561400 21.373000 19.999800 18.626600 17.253400 15.880200 14.507000
22 Belize BLZ 75.069800 73.874400 72.679000 71.840600 71.002200 70.163800 69.325400 68.487000
23 Bolivia BOL 76.503800 74.696400 72.889000 71.291200 69.693400 68.095600 66.497800 64.900000
24 Brazil BRA 66.892600 65.472800 64.053000 63.064600 62.076200 61.087800 60.099400 59.111000
25 Barbados BRB 44.557400 43.633200 42.709000 40.877200 39.045400 37.213600 35.381800 33.550000
26 Brunei Darussalam BRN 15.887400 15.164200 14.441000 13.607200 12.773400 11.939600 11.105800 10.272000
27 Bhutan BTN 35.951000 31.970000 27.989000 26.428000 24.867000 23.306000 21.745000 20.184000
28 Botswana BWA 48.354000 48.252000 48.150000 47.732200 47.314400 46.896600 46.478800 46.061000
29 Central African Republic CAF 140.637000 139.551000 138.465000 136.586800 134.708600 132.830400 130.952200 129.074000
... ... ... ... ... ... ... ... ... ... ...
210 Thailand THA 47.913800 49.738400 51.563000 50.232000 48.901000 47.570000 46.239000 44.908000
211 Tajikistan TJK 48.097600 49.262800 50.428000 51.757600 53.087200 54.416800 55.746400 57.076000
212 Turkmenistan TKM 24.732200 25.593600 26.455000 26.047600 25.640200 25.232800 24.825400 24.418000
213 Latin America & the Caribbean (IDA & IBRD coun... TLA 70.832502 69.683648 68.531037 67.511428 66.491085 65.468468 64.413533 63.367187
214 Timor-Leste TLS 44.675800 41.763400 38.851000 37.837800 36.824600 35.811400 34.798200 33.785000
215 Middle East & North Africa (IDA & IBRD countries) TMN 42.491177 43.246737 44.021652 44.116300 44.141192 44.079703 43.940974 43.754576
216 Tonga TON 17.555200 17.078600 16.602000 16.214000 15.826000 15.438000 15.050000 14.662000
217 South Asia (IDA & IBRD) TSA 43.310453 40.659584 38.007895 35.571502 33.114499 30.634980 28.117495 25.584972
218 Sub-Saharan Africa (IDA & IBRD countries) TSS 115.176701 113.552414 111.908141 110.049607 108.206224 106.385944 104.575840 102.788585
219 Trinidad and Tobago TTO 36.118200 35.461600 34.805000 33.862000 32.919000 31.976000 31.033000 30.090000
220 Tunisia TUN 7.126800 7.358400 7.590000 7.640200 7.690400 7.740600 7.790800 7.841000
221 Turkey TUR 34.151400 32.697200 31.243000 30.306200 29.369400 28.432600 27.495800 26.559000
222 Tanzania TZA 127.276000 125.218000 123.160000 122.205000 121.250000 120.295000 119.340000 118.385000
223 Uganda UGA 139.426400 135.657200 131.888000 129.277600 126.667200 124.056800 121.446400 118.836000
224 Ukraine UKR 28.936200 28.444600 27.953000 27.104600 26.256200 25.407800 24.559400 23.711000
225 Upper middle income UMC 31.068812 31.505131 31.710946 31.584812 31.386329 31.196884 30.976814 30.725634
226 Uruguay URY 60.833000 60.743000 60.653000 60.267800 59.882600 59.497400 59.112200 58.727000
227 United States USA 32.594600 30.265800 27.937000 26.321600 24.706200 23.090800 21.475400 19.860000
228 Uzbekistan UZB 21.516800 22.653400 23.790000 23.790000 23.790000 23.790000 23.790000 23.790000
229 St. Vincent and the Grenadines VCT 56.276000 55.392000 54.508000 53.410400 52.312800 51.215200 50.117600 49.020000
230 Venezuela, RB VEN 88.651600 88.235800 87.820000 87.323400 86.826800 86.330200 85.833600 85.337000
231 Virgin Islands (U.S.) VIR 47.282200 46.514600 45.747000 42.375000 39.003000 35.631000 32.259000 28.887000
232 Vietnam VNM 33.955000 35.008000 36.061000 35.034600 34.008200 32.981800 31.955400 30.929000
233 Vanuatu VUT 53.594800 53.069400 52.544000 51.922600 51.301200 50.679800 50.058400 49.437000
234 World WLD 47.806621 47.324775 46.704880 45.916746 45.088384 44.257378 43.361764 42.455699
235 Samoa WSM 29.620200 28.935600 28.251000 27.378000 26.505000 25.632000 24.759000 23.886000
236 Yemen, Rep. YEM 71.243200 69.457600 67.672000 66.208000 64.744000 63.280000 61.816000 60.352000
237 South Africa ZAF 70.088800 71.032400 71.976000 71.162400 70.348800 69.535200 68.721600 67.908000
238 Zambia ZMB 141.601200 139.148600 136.696000 133.379200 130.062400 126.745600 123.428800 120.112000
239 Zimbabwe ZWE 109.742200 109.292600 108.843000 104.301400 99.759800 95.218200 90.676600 86.135000

240 rows × 10 columns

In [63]:
x轴 = [int(x)for x in dfa1.columns.values[-8:]]
x轴
Out[63]:
[2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017]
In [64]:
dfa2=print(list(dfa1.CountryName))
dfa2
['Aruba', 'Afghanistan', 'Angola', 'Albania', 'Arab World', 'United Arab Emirates', 'Argentina', 'Armenia', 'Antigua and Barbuda', 'Australia', 'Austria', 'Azerbaijan', 'Burundi', 'Belgium', 'Benin', 'Burkina Faso', 'Bangladesh', 'Bulgaria', 'Bahrain', 'Bahamas, The', 'Bosnia and Herzegovina', 'Belarus', 'Belize', 'Bolivia', 'Brazil', 'Barbados', 'Brunei Darussalam', 'Bhutan', 'Botswana', 'Central African Republic', 'Canada', 'Central Europe and the Baltics', 'Switzerland', 'Channel Islands', 'Chile', 'China', "Cote d'Ivoire", 'Cameroon', 'Congo, Dem. Rep.', 'Congo, Rep.', 'Colombia', 'Comoros', 'Cabo Verde', 'Costa Rica', 'Caribbean small states', 'Cuba', 'Curacao', 'Cyprus', 'Czech Republic', 'Germany', 'Djibouti', 'Denmark', 'Dominican Republic', 'Algeria', 'East Asia & Pacific (excluding high income)', 'Early-demographic dividend', 'East Asia & Pacific', 'Europe & Central Asia (excluding high income)', 'Europe & Central Asia', 'Ecuador', 'Egypt, Arab Rep.', 'Euro area', 'Eritrea', 'Spain', 'Estonia', 'Ethiopia', 'European Union', 'Fragile and conflict affected situations', 'Finland', 'Fiji', 'France', 'Micronesia, Fed. Sts.', 'Gabon', 'United Kingdom', 'Georgia', 'Ghana', 'Guinea', 'Gambia, The', 'Guinea-Bissau', 'Equatorial Guinea', 'Greece', 'Grenada', 'Guatemala', 'Guam', 'Guyana', 'High income', 'Hong Kong SAR, China', 'Honduras', 'Heavily indebted poor countries (HIPC)', 'Croatia', 'Haiti', 'Hungary', 'IBRD only', 'IDA & IBRD total', 'IDA total', 'IDA blend', 'Indonesia', 'IDA only', 'India', 'Ireland', 'Iran, Islamic Rep.', 'Iraq', 'Iceland', 'Israel', 'Italy', 'Jamaica', 'Jordan', 'Japan', 'Kazakhstan', 'Kenya', 'Kyrgyz Republic', 'Cambodia', 'Kiribati', 'Korea, Rep.', 'Kuwait', 'Latin America & Caribbean (excluding high income)', 'Lao PDR', 'Lebanon', 'Liberia', 'Libya', 'St. Lucia', 'Latin America & Caribbean', 'Least developed countries: UN classification', 'Low income', 'Sri Lanka', 'Lower middle income', 'Low & middle income', 'Lesotho', 'Late-demographic dividend', 'Lithuania', 'Luxembourg', 'Latvia', 'Macao SAR, China', 'Morocco', 'Moldova', 'Madagascar', 'Maldives', 'Middle East & North Africa', 'Mexico', 'Middle income', 'North Macedonia', 'Mali', 'Malta', 'Myanmar', 'Middle East & North Africa (excluding high income)', 'Montenegro', 'Mongolia', 'Mozambique', 'Mauritania', 'Mauritius', 'Malawi', 'Malaysia', 'North America', 'Namibia', 'New Caledonia', 'Niger', 'Nigeria', 'Nicaragua', 'Netherlands', 'Norway', 'Nepal', 'New Zealand', 'OECD members', 'Oman', 'Other small states', 'Pakistan', 'Panama', 'Peru', 'Philippines', 'Papua New Guinea', 'Poland', 'Pre-demographic dividend', 'Puerto Rico', 'Korea, Dem. People’s Rep.', 'Portugal', 'Paraguay', 'West Bank and Gaza', 'Pacific island small states', 'Post-demographic dividend', 'French Polynesia', 'Qatar', 'Romania', 'Russian Federation', 'Rwanda', 'South Asia', 'Saudi Arabia', 'Sudan', 'Senegal', 'Singapore', 'Solomon Islands', 'Sierra Leone', 'El Salvador', 'Somalia', 'Serbia', 'Sub-Saharan Africa (excluding high income)', 'South Sudan', 'Sub-Saharan Africa', 'Small states', 'Sao Tome and Principe', 'Suriname', 'Slovak Republic', 'Slovenia', 'Sweden', 'Eswatini', 'Seychelles', 'Syrian Arab Republic', 'Chad', 'East Asia & Pacific (IDA & IBRD countries)', 'Europe & Central Asia (IDA & IBRD countries)', 'Togo', 'Thailand', 'Tajikistan', 'Turkmenistan', 'Latin America & the Caribbean (IDA & IBRD countries)', 'Timor-Leste', 'Middle East & North Africa (IDA & IBRD countries)', 'Tonga', 'South Asia (IDA & IBRD)', 'Sub-Saharan Africa (IDA & IBRD countries)', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Tanzania', 'Uganda', 'Ukraine', 'Upper middle income', 'Uruguay', 'United States', 'Uzbekistan', 'St. Vincent and the Grenadines', 'Venezuela, RB', 'Virgin Islands (U.S.)', 'Vietnam', 'Vanuatu', 'World', 'Samoa', 'Yemen, Rep.', 'South Africa', 'Zambia', 'Zimbabwe']
In [65]:
青少年怀孕率= list(zip(list(dfa1.CountryName)))
print(青少年怀孕率)
print(type(青少年怀孕率))
[('Aruba',), ('Afghanistan',), ('Angola',), ('Albania',), ('Arab World',), ('United Arab Emirates',), ('Argentina',), ('Armenia',), ('Antigua and Barbuda',), ('Australia',), ('Austria',), ('Azerbaijan',), ('Burundi',), ('Belgium',), ('Benin',), ('Burkina Faso',), ('Bangladesh',), ('Bulgaria',), ('Bahrain',), ('Bahamas, The',), ('Bosnia and Herzegovina',), ('Belarus',), ('Belize',), ('Bolivia',), ('Brazil',), ('Barbados',), ('Brunei Darussalam',), ('Bhutan',), ('Botswana',), ('Central African Republic',), ('Canada',), ('Central Europe and the Baltics',), ('Switzerland',), ('Channel Islands',), ('Chile',), ('China',), ("Cote d'Ivoire",), ('Cameroon',), ('Congo, Dem. Rep.',), ('Congo, Rep.',), ('Colombia',), ('Comoros',), ('Cabo Verde',), ('Costa Rica',), ('Caribbean small states',), ('Cuba',), ('Curacao',), ('Cyprus',), ('Czech Republic',), ('Germany',), ('Djibouti',), ('Denmark',), ('Dominican Republic',), ('Algeria',), ('East Asia & Pacific (excluding high income)',), ('Early-demographic dividend',), ('East Asia & Pacific',), ('Europe & Central Asia (excluding high income)',), ('Europe & Central Asia',), ('Ecuador',), ('Egypt, Arab Rep.',), ('Euro area',), ('Eritrea',), ('Spain',), ('Estonia',), ('Ethiopia',), ('European Union',), ('Fragile and conflict affected situations',), ('Finland',), ('Fiji',), ('France',), ('Micronesia, Fed. Sts.',), ('Gabon',), ('United Kingdom',), ('Georgia',), ('Ghana',), ('Guinea',), ('Gambia, The',), ('Guinea-Bissau',), ('Equatorial Guinea',), ('Greece',), ('Grenada',), ('Guatemala',), ('Guam',), ('Guyana',), ('High income',), ('Hong Kong SAR, China',), ('Honduras',), ('Heavily indebted poor countries (HIPC)',), ('Croatia',), ('Haiti',), ('Hungary',), ('IBRD only',), ('IDA & IBRD total',), ('IDA total',), ('IDA blend',), ('Indonesia',), ('IDA only',), ('India',), ('Ireland',), ('Iran, Islamic Rep.',), ('Iraq',), ('Iceland',), ('Israel',), ('Italy',), ('Jamaica',), ('Jordan',), ('Japan',), ('Kazakhstan',), ('Kenya',), ('Kyrgyz Republic',), ('Cambodia',), ('Kiribati',), ('Korea, Rep.',), ('Kuwait',), ('Latin America & Caribbean (excluding high income)',), ('Lao PDR',), ('Lebanon',), ('Liberia',), ('Libya',), ('St. Lucia',), ('Latin America & Caribbean',), ('Least developed countries: UN classification',), ('Low income',), ('Sri Lanka',), ('Lower middle income',), ('Low & middle income',), ('Lesotho',), ('Late-demographic dividend',), ('Lithuania',), ('Luxembourg',), ('Latvia',), ('Macao SAR, China',), ('Morocco',), ('Moldova',), ('Madagascar',), ('Maldives',), ('Middle East & North Africa',), ('Mexico',), ('Middle income',), ('North Macedonia',), ('Mali',), ('Malta',), ('Myanmar',), ('Middle East & North Africa (excluding high income)',), ('Montenegro',), ('Mongolia',), ('Mozambique',), ('Mauritania',), ('Mauritius',), ('Malawi',), ('Malaysia',), ('North America',), ('Namibia',), ('New Caledonia',), ('Niger',), ('Nigeria',), ('Nicaragua',), ('Netherlands',), ('Norway',), ('Nepal',), ('New Zealand',), ('OECD members',), ('Oman',), ('Other small states',), ('Pakistan',), ('Panama',), ('Peru',), ('Philippines',), ('Papua New Guinea',), ('Poland',), ('Pre-demographic dividend',), ('Puerto Rico',), ('Korea, Dem. People’s Rep.',), ('Portugal',), ('Paraguay',), ('West Bank and Gaza',), ('Pacific island small states',), ('Post-demographic dividend',), ('French Polynesia',), ('Qatar',), ('Romania',), ('Russian Federation',), ('Rwanda',), ('South Asia',), ('Saudi Arabia',), ('Sudan',), ('Senegal',), ('Singapore',), ('Solomon Islands',), ('Sierra Leone',), ('El Salvador',), ('Somalia',), ('Serbia',), ('Sub-Saharan Africa (excluding high income)',), ('South Sudan',), ('Sub-Saharan Africa',), ('Small states',), ('Sao Tome and Principe',), ('Suriname',), ('Slovak Republic',), ('Slovenia',), ('Sweden',), ('Eswatini',), ('Seychelles',), ('Syrian Arab Republic',), ('Chad',), ('East Asia & Pacific (IDA & IBRD countries)',), ('Europe & Central Asia (IDA & IBRD countries)',), ('Togo',), ('Thailand',), ('Tajikistan',), ('Turkmenistan',), ('Latin America & the Caribbean (IDA & IBRD countries)',), ('Timor-Leste',), ('Middle East & North Africa (IDA & IBRD countries)',), ('Tonga',), ('South Asia (IDA & IBRD)',), ('Sub-Saharan Africa (IDA & IBRD countries)',), ('Trinidad and Tobago',), ('Tunisia',), ('Turkey',), ('Tanzania',), ('Uganda',), ('Ukraine',), ('Upper middle income',), ('Uruguay',), ('United States',), ('Uzbekistan',), ('St. Vincent and the Grenadines',), ('Venezuela, RB',), ('Virgin Islands (U.S.)',), ('Vietnam',), ('Vanuatu',), ('World',), ('Samoa',), ('Yemen, Rep.',), ('South Africa',), ('Zambia',), ('Zimbabwe',)]
<class 'list'>
In [67]:
from pyecharts.faker import Faker

from pyecharts.charts import Map
from pyecharts import options as opts
from pyecharts.globals import ChartType, SymbolType

def timeline_map() -> Timeline:
    tl = Timeline()
    for i in range(2010,2017):
        map0 = (
            Map()
            .add(
                "青少年怀孕率", (list(zip(list(dfa1.CountryName),list(dfa1["{}".format(i)])))), "world",is_map_symbol_show = False
            )
            .set_global_opts(
                title_opts=opts.TitleOpts(title="".format(i),subtitle="",
                                         subtitle_textstyle_opts=opts.TextStyleOpts(color="red",font_size=16,font_style="italic")),
                visualmap_opts=opts.VisualMapOpts(min_=0, max_=100,series_index=0),
            
            )
        )
        tl.add(map0, "{}".format(i))
    return tl

timeline_map().render_notebook()
Out[67]:

全球青少年怀孕率分析:

  • 以上轮播数据图表所显示的是2010年到2016年全球青少年怀孕率的数据分布图,从轮播地图上我们可以看到非洲国家的青少年怀孕率普遍较高,而欧洲和北美洲的青少年怀孕率较低;从时间的宏观角度去分析,虽然非洲地区的青少年怀孕率相比起其他国家要高出很多,但是从国家的数据上看,他们从2010年到2016年青少年怀孕率都是在逐年减少的趋势,当然从全球的数据来看,全球的青少年怀孕率也是呈现一个下降的趋势。
In [72]:
dfb = pd.read_csv('GDP.csv',encoding = 'utf8')
In [73]:
dfb
Out[73]:
CountryName 2010 2011 2012 2013 2014 2015 2016 2017 2018
0 Aruba 23512.602600 24985.993280 24713.698050 25025.099560 25533.569780 25796.380250 25239.600410 25630.266490 NaN
1 Afghanistan 543.303042 591.162347 641.872034 637.165044 613.856333 578.466353 547.228110 556.302138 520.896603
2 Angola 3587.883798 4615.468028 5100.095808 5254.882338 5408.410496 4166.979684 3506.072885 4095.812942 3432.385736
3 Albania 4094.358816 4437.177794 4247.614342 4413.082887 4578.667934 3952.830781 4124.108543 4532.889198 5253.630064
4 Andorra 39736.354060 41100.729940 38392.943900 40626.751630 42300.334130 36039.653500 37224.108920 39134.393370 42029.762740
5 Arab World 5945.678558 6889.091806 7503.174184 7551.282834 7497.556427 6459.109379 6202.890459 6285.215228 6626.135357
6 United Arab Emirates 33893.303510 39194.676620 40976.499710 42412.630280 43751.838890 38663.383810 38141.846760 40325.382000 43004.948650
7 Argentina 10385.964430 12848.864200 13082.664330 13080.254730 12334.798250 13789.060420 12790.242470 14591.863380 11652.566290
8 Armenia 3218.372707 3525.804747 3681.857456 3838.185801 3986.231624 3607.296697 3591.829276 3914.501268 4212.070943
9 American Samoa 10271.224520 10294.302270 11568.793000 11505.393710 11525.156390 11843.331180 11714.895680 11398.777420 NaN
10 Antigua and Barbuda 13092.073820 12795.569070 13399.237950 13035.093640 13780.782370 14526.588080 15494.305470 15824.667810 16864.383360
11 Australia 52022.125600 62517.833750 68012.147900 68150.107040 62510.791170 56748.420260 50019.967770 54093.602190 57305.299020
12 Austria 46858.043270 51374.958410 48567.695290 50716.708710 51717.495940 44176.671740 45103.329810 47380.829640 51512.905480
13 Azerbaijan 5842.805784 7189.691229 7496.294648 7875.756953 7891.313147 5500.320497 3880.738731 4147.089716 4721.178087
14 Burundi 234.235647 249.577979 252.358980 256.976003 274.857948 305.549773 282.149681 293.009062 275.429603
15 Belgium 44380.176630 47743.780530 44826.439610 46680.389820 47355.312010 40441.052040 41449.097360 43507.238200 46556.099570
16 Benin 757.695907 825.940341 837.942921 915.315621 943.674649 783.963078 788.549196 827.429810 901.954052
17 Burkina Faso 575.446453 666.840120 673.821598 699.779406 703.820056 575.314454 583.832620 642.040426 731.171717
18 Bangladesh 781.153594 861.758444 883.105001 981.839879 1118.853663 1248.453398 1401.620628 1563.994082 1698.262802
19 Bulgaria 6843.266950 7813.806692 7378.024730 7646.839866 7864.760672 6993.783483 7469.455638 8228.011570 9272.629304
20 Bahrain 20722.137290 22514.237950 23654.351390 24744.357630 24989.400120 22688.944400 22619.116670 23715.482750 24050.757510
21 Bahamas, The 28443.407660 28006.379720 29485.620930 28944.788220 29563.746350 31512.856550 31325.294830 31857.890150 NaN
22 Bosnia and Herzegovina 4635.517779 5092.551943 4778.636088 5131.394506 5329.635045 4727.277546 4994.683140 5394.591220 5951.323299
23 Belarus 6181.399916 6519.230195 6940.159254 7978.872615 8318.512690 5949.106307 5022.626643 5761.747120 6289.938553
24 Belize 4331.434517 4501.602637 4626.709615 4652.509003 4790.941262 4883.179011 4904.034338 4956.808039 5025.178100
25 Bermuda 88207.327560 85973.158420 85458.455510 85748.065410 NaN NaN NaN NaN NaN
26 Bolivia 1955.461557 2346.337170 2609.880819 2908.200085 3081.878834 3035.972215 3076.658949 3351.124053 3548.590140
27 Brazil 11286.243020 13245.615530 12370.024200 12300.322580 12112.590300 8814.000987 8712.887044 9880.946543 8920.762105
28 Barbados 16056.016530 16470.367900 16412.936200 16224.287360 16179.583960 16066.471800 15847.142720 16327.607230 NaN
29 Brunei Darussalam 35269.553110 47055.841120 47741.906470 44740.085020 41726.783970 31164.562030 27157.346230 28572.109420 31627.742080
... ... ... ... ... ... ... ... ... ... ...
235 Timor-Leste 3656.952175 5095.489043 5879.699782 4888.317123 3441.650571 2585.153878 2053.273798 2000.601191 2035.533908
236 Middle East & North Africa (IDA & IBRD countries) 4178.685372 4652.157905 5036.026187 4641.495942 4485.983790 3972.175733 3934.616702 3823.833200 NaN
237 Tonga 3553.220614 4084.624132 4597.742305 4428.566481 4393.940811 4320.637990 3966.156520 4217.476507 4364.015561
238 South Asia (IDA & IBRD) 1257.669490 1367.338787 1364.441602 1381.881309 1494.461188 1541.835813 1648.678479 1867.272248 1905.766410
239 Sub-Saharan Africa (IDA & IBRD countries) 1576.176004 1738.475720 1782.408543 1844.577249 1885.558172 1669.443418 1511.304900 1599.336187 1574.197871
240 Trinidad and Tobago 16683.355380 19034.149200 19161.959910 20026.787530 20169.653010 18332.490310 15786.120520 16076.082040 16843.701610
241 Tunisia 4141.976353 4264.674946 4152.678587 4222.703245 4305.474165 3859.814436 3698.565075 3494.318864 3446.607238
242 Turkey 10672.389250 11335.510510 11707.259710 12519.391430 12095.854570 10948.724610 10820.633840 10499.745570 9311.366117
243 Tuvalu 3022.288820 3640.861433 3507.936911 3454.684953 3398.818942 3197.795645 3255.894866 3572.608367 3700.710677
244 Tanzania 743.403785 781.437014 867.867681 970.416938 1030.092917 947.933446 966.474622 1004.841121 1050.675254
245 Uganda 622.498846 602.684651 668.832462 689.154814 739.373927 709.021039 608.705735 631.522720 643.139670
246 Ukraine 2965.142365 3569.757027 3855.421280 4029.715504 3104.658296 2124.662666 2187.731997 2640.675677 3095.173581
247 Upper middle income 6344.152969 7533.005863 8009.525571 8448.564499 8651.290227 8032.489459 7921.734348 8663.273890 9200.453954
248 Uruguay 11992.016630 14236.681190 15171.584660 16973.674210 16831.972940 15613.764270 15387.144030 16437.244870 17277.970110
249 United States 48466.823380 49883.113980 51603.497260 53106.909770 55032.958000 56803.472430 57904.201960 59927.929830 62641.014570
250 Uzbekistan 1377.082140 1564.966945 1740.468298 1907.561704 2492.336643 2615.025134 2567.799418 1826.567040 1532.371639
251 St. Vincent and the Grenadines 6292.789829 6242.193281 6390.314389 6639.621791 6684.803622 6921.409750 7041.560804 7149.630866 7377.678832
252 Venezuela, RB 13825.358090 10955.349910 12985.505330 12456.712450 16054.490510 NaN NaN NaN NaN
253 British Virgin Islands NaN NaN NaN NaN NaN NaN NaN NaN NaN
254 Virgin Islands (U.S.) 40043.190170 39144.165770 37849.728720 34819.147750 33573.097030 34797.140470 35931.541250 35938.024390 NaN
255 Vietnam 1317.890706 1525.115988 1735.141276 1886.671896 2030.261955 2085.101484 2192.214539 2365.621666 2563.820731
256 Vanuatu 2966.857116 3264.537017 3133.090209 3124.233078 3088.258303 2721.635936 2830.965284 2976.107116 3033.408146
257 World 9538.846778 10473.629970 10589.208470 10764.191770 10928.871160 10217.656010 10247.936230 10769.677110 11298.303710
258 Samoa 3458.188715 3946.173084 4237.014630 4219.909738 4188.733679 4155.279353 4043.694000 4307.805464 4392.467755
259 Kosovo 3283.510304 3736.363217 3600.673475 3876.958302 4054.721339 3574.543333 3697.121677 3948.088150 4281.292329
260 Yemen, Rep. 1334.784845 1374.621313 1446.536280 1607.152275 1674.002766 1608.744312 1139.870568 963.494721 944.408499
261 South Africa 7328.593646 8007.377412 7501.407280 6829.020465 6428.293579 5730.934174 5272.627749 6127.462297 6374.015446
262 Zambia 1489.459070 1672.949830 1763.094184 1878.903489 1763.056239 1332.194321 1280.578447 1534.865371 1539.900158
263 Zimbabwe 948.331854 1093.654002 1304.969802 1430.000818 1434.899340 1445.071062 1464.583529 1602.403507 2146.996385
264 Russian 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000

265 rows × 10 columns

In [74]:
dfb1 =dfb.dropna(axis=0,how='any') 
dfb1
Out[74]:
CountryName 2010 2011 2012 2013 2014 2015 2016 2017 2018
1 Afghanistan 543.303042 591.162347 641.872034 637.165044 613.856333 578.466353 547.228110 556.302138 520.896603
2 Angola 3587.883798 4615.468028 5100.095808 5254.882338 5408.410496 4166.979684 3506.072885 4095.812942 3432.385736
3 Albania 4094.358816 4437.177794 4247.614342 4413.082887 4578.667934 3952.830781 4124.108543 4532.889198 5253.630064
4 Andorra 39736.354060 41100.729940 38392.943900 40626.751630 42300.334130 36039.653500 37224.108920 39134.393370 42029.762740
5 Arab World 5945.678558 6889.091806 7503.174184 7551.282834 7497.556427 6459.109379 6202.890459 6285.215228 6626.135357
6 United Arab Emirates 33893.303510 39194.676620 40976.499710 42412.630280 43751.838890 38663.383810 38141.846760 40325.382000 43004.948650
7 Argentina 10385.964430 12848.864200 13082.664330 13080.254730 12334.798250 13789.060420 12790.242470 14591.863380 11652.566290
8 Armenia 3218.372707 3525.804747 3681.857456 3838.185801 3986.231624 3607.296697 3591.829276 3914.501268 4212.070943
10 Antigua and Barbuda 13092.073820 12795.569070 13399.237950 13035.093640 13780.782370 14526.588080 15494.305470 15824.667810 16864.383360
11 Australia 52022.125600 62517.833750 68012.147900 68150.107040 62510.791170 56748.420260 50019.967770 54093.602190 57305.299020
12 Austria 46858.043270 51374.958410 48567.695290 50716.708710 51717.495940 44176.671740 45103.329810 47380.829640 51512.905480
13 Azerbaijan 5842.805784 7189.691229 7496.294648 7875.756953 7891.313147 5500.320497 3880.738731 4147.089716 4721.178087
14 Burundi 234.235647 249.577979 252.358980 256.976003 274.857948 305.549773 282.149681 293.009062 275.429603
15 Belgium 44380.176630 47743.780530 44826.439610 46680.389820 47355.312010 40441.052040 41449.097360 43507.238200 46556.099570
16 Benin 757.695907 825.940341 837.942921 915.315621 943.674649 783.963078 788.549196 827.429810 901.954052
17 Burkina Faso 575.446453 666.840120 673.821598 699.779406 703.820056 575.314454 583.832620 642.040426 731.171717
18 Bangladesh 781.153594 861.758444 883.105001 981.839879 1118.853663 1248.453398 1401.620628 1563.994082 1698.262802
19 Bulgaria 6843.266950 7813.806692 7378.024730 7646.839866 7864.760672 6993.783483 7469.455638 8228.011570 9272.629304
20 Bahrain 20722.137290 22514.237950 23654.351390 24744.357630 24989.400120 22688.944400 22619.116670 23715.482750 24050.757510
22 Bosnia and Herzegovina 4635.517779 5092.551943 4778.636088 5131.394506 5329.635045 4727.277546 4994.683140 5394.591220 5951.323299
23 Belarus 6181.399916 6519.230195 6940.159254 7978.872615 8318.512690 5949.106307 5022.626643 5761.747120 6289.938553
24 Belize 4331.434517 4501.602637 4626.709615 4652.509003 4790.941262 4883.179011 4904.034338 4956.808039 5025.178100
26 Bolivia 1955.461557 2346.337170 2609.880819 2908.200085 3081.878834 3035.972215 3076.658949 3351.124053 3548.590140
27 Brazil 11286.243020 13245.615530 12370.024200 12300.322580 12112.590300 8814.000987 8712.887044 9880.946543 8920.762105
29 Brunei Darussalam 35269.553110 47055.841120 47741.906470 44740.085020 41726.783970 31164.562030 27157.346230 28572.109420 31627.742080
30 Bhutan 2312.860096 2625.433256 2599.396094 2532.015642 2749.352665 2829.891245 3012.961401 3390.714075 3360.266867
31 Botswana 6434.815657 7617.325094 7877.790350 7224.965172 7780.638385 6799.875234 7243.856017 7893.675933 8258.641666
32 Central African Republic 487.945383 551.028058 565.833058 382.340300 426.684562 380.404293 406.531961 471.603228 509.970975
33 Canada 47450.318470 52101.796090 52542.346660 52504.655700 50835.511180 43495.054390 42279.900820 45069.927250 46210.547620
34 Central Europe and the Baltics 12567.405000 13872.615410 12998.665270 13710.080620 14152.393830 12467.450180 12773.783840 14167.649100 15913.231680
... ... ... ... ... ... ... ... ... ... ...
231 Thailand 5076.342992 5492.115427 5860.580610 6168.264895 5951.883702 5840.046948 5978.611454 6578.188865 7273.563207
232 Tajikistan 749.552711 847.382102 969.296473 1048.227293 1104.171689 929.095857 802.518004 806.041573 826.621530
233 Turkmenistan 4439.200382 5649.952278 6675.185658 7304.287132 7962.239098 6432.680702 6389.548408 6587.090316 6966.635411
234 Latin America & the Caribbean (IDA & IBRD coun... 8974.007984 10119.523470 10102.295630 10237.807170 10322.942390 8716.406758 8404.752742 9253.666484 8881.077105
235 Timor-Leste 3656.952175 5095.489043 5879.699782 4888.317123 3441.650571 2585.153878 2053.273798 2000.601191 2035.533908
237 Tonga 3553.220614 4084.624132 4597.742305 4428.566481 4393.940811 4320.637990 3966.156520 4217.476507 4364.015561
238 South Asia (IDA & IBRD) 1257.669490 1367.338787 1364.441602 1381.881309 1494.461188 1541.835813 1648.678479 1867.272248 1905.766410
239 Sub-Saharan Africa (IDA & IBRD countries) 1576.176004 1738.475720 1782.408543 1844.577249 1885.558172 1669.443418 1511.304900 1599.336187 1574.197871
240 Trinidad and Tobago 16683.355380 19034.149200 19161.959910 20026.787530 20169.653010 18332.490310 15786.120520 16076.082040 16843.701610
241 Tunisia 4141.976353 4264.674946 4152.678587 4222.703245 4305.474165 3859.814436 3698.565075 3494.318864 3446.607238
242 Turkey 10672.389250 11335.510510 11707.259710 12519.391430 12095.854570 10948.724610 10820.633840 10499.745570 9311.366117
243 Tuvalu 3022.288820 3640.861433 3507.936911 3454.684953 3398.818942 3197.795645 3255.894866 3572.608367 3700.710677
244 Tanzania 743.403785 781.437014 867.867681 970.416938 1030.092917 947.933446 966.474622 1004.841121 1050.675254
245 Uganda 622.498846 602.684651 668.832462 689.154814 739.373927 709.021039 608.705735 631.522720 643.139670
246 Ukraine 2965.142365 3569.757027 3855.421280 4029.715504 3104.658296 2124.662666 2187.731997 2640.675677 3095.173581
247 Upper middle income 6344.152969 7533.005863 8009.525571 8448.564499 8651.290227 8032.489459 7921.734348 8663.273890 9200.453954
248 Uruguay 11992.016630 14236.681190 15171.584660 16973.674210 16831.972940 15613.764270 15387.144030 16437.244870 17277.970110
249 United States 48466.823380 49883.113980 51603.497260 53106.909770 55032.958000 56803.472430 57904.201960 59927.929830 62641.014570
250 Uzbekistan 1377.082140 1564.966945 1740.468298 1907.561704 2492.336643 2615.025134 2567.799418 1826.567040 1532.371639
251 St. Vincent and the Grenadines 6292.789829 6242.193281 6390.314389 6639.621791 6684.803622 6921.409750 7041.560804 7149.630866 7377.678832
255 Vietnam 1317.890706 1525.115988 1735.141276 1886.671896 2030.261955 2085.101484 2192.214539 2365.621666 2563.820731
256 Vanuatu 2966.857116 3264.537017 3133.090209 3124.233078 3088.258303 2721.635936 2830.965284 2976.107116 3033.408146
257 World 9538.846778 10473.629970 10589.208470 10764.191770 10928.871160 10217.656010 10247.936230 10769.677110 11298.303710
258 Samoa 3458.188715 3946.173084 4237.014630 4219.909738 4188.733679 4155.279353 4043.694000 4307.805464 4392.467755
259 Kosovo 3283.510304 3736.363217 3600.673475 3876.958302 4054.721339 3574.543333 3697.121677 3948.088150 4281.292329
260 Yemen, Rep. 1334.784845 1374.621313 1446.536280 1607.152275 1674.002766 1608.744312 1139.870568 963.494721 944.408499
261 South Africa 7328.593646 8007.377412 7501.407280 6829.020465 6428.293579 5730.934174 5272.627749 6127.462297 6374.015446
262 Zambia 1489.459070 1672.949830 1763.094184 1878.903489 1763.056239 1332.194321 1280.578447 1534.865371 1539.900158
263 Zimbabwe 948.331854 1093.654002 1304.969802 1430.000818 1434.899340 1445.071062 1464.583529 1602.403507 2146.996385
264 Russian 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000 20000.000000

231 rows × 10 columns

In [75]:
x轴 = [int(x)for x in dfb1.columns.values[-8:]]
x轴
Out[75]:
[2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018]
In [76]:
dfb2=print(list(dfb1.CountryName))
dfb2
['Afghanistan', 'Angola', 'Albania', 'Andorra', 'Arab World', 'United Arab Emirates', 'Argentina', 'Armenia', 'Antigua and Barbuda', 'Australia', 'Austria', 'Azerbaijan', 'Burundi', 'Belgium', 'Benin', 'Burkina Faso', 'Bangladesh', 'Bulgaria', 'Bahrain', 'Bosnia and Herzegovina', 'Belarus', 'Belize', 'Bolivia', 'Brazil', 'Brunei Darussalam', 'Bhutan', 'Botswana', 'Central African Republic', 'Canada', 'Central Europe and the Baltics', 'Switzerland', 'Chile', 'China', "Cote d'Ivoire", 'Cameroon', 'Congo, Dem. Rep.', 'Congo, Rep.', 'Colombia', 'Comoros', 'Cabo Verde', 'Costa Rica', 'Caribbean small states', 'Cyprus', 'Czech Republic', 'Germany', 'Djibouti', 'Dominica', 'Denmark', 'Dominican Republic', 'Algeria', 'East Asia & Pacific (excluding high income)', 'Early-demographic dividend', 'East Asia & Pacific', 'Europe & Central Asia (excluding high income)', 'Europe & Central Asia', 'Ecuador', 'Egypt, Arab Rep.', 'Euro area', 'Spain', 'Estonia', 'Ethiopia', 'European Union', 'Fragile and conflict affected situations', 'Finland', 'Fiji', 'France', 'Micronesia, Fed. Sts.', 'Gabon', 'United Kingdom', 'Georgia', 'Ghana', 'Guinea', 'Gambia, The', 'Guinea-Bissau', 'Equatorial Guinea', 'Greece', 'Grenada', 'Guatemala', 'Guyana', 'High income', 'Hong Kong SAR, China', 'Honduras', 'Heavily indebted poor countries (HIPC)', 'Croatia', 'Haiti', 'Hungary', 'IBRD only', 'IDA & IBRD total', 'IDA total', 'IDA blend', 'Indonesia', 'IDA only', 'India', 'Ireland', 'Iraq', 'Iceland', 'Israel', 'Italy', 'Jamaica', 'Jordan', 'Japan', 'Kazakhstan', 'Kenya', 'Kyrgyz Republic', 'Cambodia', 'Kiribati', 'St. Kitts and Nevis', 'Korea, Rep.', 'Kuwait', 'Latin America & Caribbean (excluding high income)', 'Lao PDR', 'Lebanon', 'Liberia', 'Libya', 'St. Lucia', 'Latin America & Caribbean', 'Least developed countries: UN classification', 'Low income', 'Sri Lanka', 'Lower middle income', 'Low & middle income', 'Lesotho', 'Late-demographic dividend', 'Lithuania', 'Luxembourg', 'Latvia', 'Macao SAR, China', 'Morocco', 'Moldova', 'Madagascar', 'Maldives', 'Middle East & North Africa', 'Mexico', 'Marshall Islands', 'Middle income', 'North Macedonia', 'Mali', 'Malta', 'Myanmar', 'Montenegro', 'Mongolia', 'Mozambique', 'Mauritania', 'Mauritius', 'Malawi', 'Malaysia', 'North America', 'Namibia', 'Niger', 'Nigeria', 'Nicaragua', 'Netherlands', 'Norway', 'Nepal', 'Nauru', 'New Zealand', 'OECD members', 'Oman', 'Other small states', 'Pakistan', 'Panama', 'Peru', 'Philippines', 'Palau', 'Papua New Guinea', 'Poland', 'Pre-demographic dividend', 'Puerto Rico', 'Portugal', 'Paraguay', 'West Bank and Gaza', 'Pacific island small states', 'Post-demographic dividend', 'Qatar', 'Romania', 'Russian Federation', 'Rwanda', 'South Asia', 'Saudi Arabia', 'Sudan', 'Senegal', 'Singapore', 'Solomon Islands', 'Sierra Leone', 'El Salvador', 'Serbia', 'Sub-Saharan Africa (excluding high income)', 'Sub-Saharan Africa', 'Small states', 'Sao Tome and Principe', 'Suriname', 'Slovak Republic', 'Slovenia', 'Sweden', 'Eswatini', 'Seychelles', 'Turks and Caicos Islands', 'Chad', 'East Asia & Pacific (IDA & IBRD countries)', 'Europe & Central Asia (IDA & IBRD countries)', 'Togo', 'Thailand', 'Tajikistan', 'Turkmenistan', 'Latin America & the Caribbean (IDA & IBRD countries)', 'Timor-Leste', 'Tonga', 'South Asia (IDA & IBRD)', 'Sub-Saharan Africa (IDA & IBRD countries)', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Tuvalu', 'Tanzania', 'Uganda', 'Ukraine', 'Upper middle income', 'Uruguay', 'United States', 'Uzbekistan', 'St. Vincent and the Grenadines', 'Vietnam', 'Vanuatu', 'World', 'Samoa', 'Kosovo', 'Yemen, Rep.', 'South Africa', 'Zambia', 'Zimbabwe', 'Russian']
In [77]:
全球人均GDP= list(zip(list(dfb1.CountryName)))
print(全球人均GDP)
print(type(全球人均GDP))
[('Afghanistan',), ('Angola',), ('Albania',), ('Andorra',), ('Arab World',), ('United Arab Emirates',), ('Argentina',), ('Armenia',), ('Antigua and Barbuda',), ('Australia',), ('Austria',), ('Azerbaijan',), ('Burundi',), ('Belgium',), ('Benin',), ('Burkina Faso',), ('Bangladesh',), ('Bulgaria',), ('Bahrain',), ('Bosnia and Herzegovina',), ('Belarus',), ('Belize',), ('Bolivia',), ('Brazil',), ('Brunei Darussalam',), ('Bhutan',), ('Botswana',), ('Central African Republic',), ('Canada',), ('Central Europe and the Baltics',), ('Switzerland',), ('Chile',), ('China',), ("Cote d'Ivoire",), ('Cameroon',), ('Congo, Dem. Rep.',), ('Congo, Rep.',), ('Colombia',), ('Comoros',), ('Cabo Verde',), ('Costa Rica',), ('Caribbean small states',), ('Cyprus',), ('Czech Republic',), ('Germany',), ('Djibouti',), ('Dominica',), ('Denmark',), ('Dominican Republic',), ('Algeria',), ('East Asia & Pacific (excluding high income)',), ('Early-demographic dividend',), ('East Asia & Pacific',), ('Europe & Central Asia (excluding high income)',), ('Europe & Central Asia',), ('Ecuador',), ('Egypt, Arab Rep.',), ('Euro area',), ('Spain',), ('Estonia',), ('Ethiopia',), ('European Union',), ('Fragile and conflict affected situations',), ('Finland',), ('Fiji',), ('France',), ('Micronesia, Fed. Sts.',), ('Gabon',), ('United Kingdom',), ('Georgia',), ('Ghana',), ('Guinea',), ('Gambia, The',), ('Guinea-Bissau',), ('Equatorial Guinea',), ('Greece',), ('Grenada',), ('Guatemala',), ('Guyana',), ('High income',), ('Hong Kong SAR, China',), ('Honduras',), ('Heavily indebted poor countries (HIPC)',), ('Croatia',), ('Haiti',), ('Hungary',), ('IBRD only',), ('IDA & IBRD total',), ('IDA total',), ('IDA blend',), ('Indonesia',), ('IDA only',), ('India',), ('Ireland',), ('Iraq',), ('Iceland',), ('Israel',), ('Italy',), ('Jamaica',), ('Jordan',), ('Japan',), ('Kazakhstan',), ('Kenya',), ('Kyrgyz Republic',), ('Cambodia',), ('Kiribati',), ('St. Kitts and Nevis',), ('Korea, Rep.',), ('Kuwait',), ('Latin America & Caribbean (excluding high income)',), ('Lao PDR',), ('Lebanon',), ('Liberia',), ('Libya',), ('St. Lucia',), ('Latin America & Caribbean',), ('Least developed countries: UN classification',), ('Low income',), ('Sri Lanka',), ('Lower middle income',), ('Low & middle income',), ('Lesotho',), ('Late-demographic dividend',), ('Lithuania',), ('Luxembourg',), ('Latvia',), ('Macao SAR, China',), ('Morocco',), ('Moldova',), ('Madagascar',), ('Maldives',), ('Middle East & North Africa',), ('Mexico',), ('Marshall Islands',), ('Middle income',), ('North Macedonia',), ('Mali',), ('Malta',), ('Myanmar',), ('Montenegro',), ('Mongolia',), ('Mozambique',), ('Mauritania',), ('Mauritius',), ('Malawi',), ('Malaysia',), ('North America',), ('Namibia',), ('Niger',), ('Nigeria',), ('Nicaragua',), ('Netherlands',), ('Norway',), ('Nepal',), ('Nauru',), ('New Zealand',), ('OECD members',), ('Oman',), ('Other small states',), ('Pakistan',), ('Panama',), ('Peru',), ('Philippines',), ('Palau',), ('Papua New Guinea',), ('Poland',), ('Pre-demographic dividend',), ('Puerto Rico',), ('Portugal',), ('Paraguay',), ('West Bank and Gaza',), ('Pacific island small states',), ('Post-demographic dividend',), ('Qatar',), ('Romania',), ('Russian Federation',), ('Rwanda',), ('South Asia',), ('Saudi Arabia',), ('Sudan',), ('Senegal',), ('Singapore',), ('Solomon Islands',), ('Sierra Leone',), ('El Salvador',), ('Serbia',), ('Sub-Saharan Africa (excluding high income)',), ('Sub-Saharan Africa',), ('Small states',), ('Sao Tome and Principe',), ('Suriname',), ('Slovak Republic',), ('Slovenia',), ('Sweden',), ('Eswatini',), ('Seychelles',), ('Turks and Caicos Islands',), ('Chad',), ('East Asia & Pacific (IDA & IBRD countries)',), ('Europe & Central Asia (IDA & IBRD countries)',), ('Togo',), ('Thailand',), ('Tajikistan',), ('Turkmenistan',), ('Latin America & the Caribbean (IDA & IBRD countries)',), ('Timor-Leste',), ('Tonga',), ('South Asia (IDA & IBRD)',), ('Sub-Saharan Africa (IDA & IBRD countries)',), ('Trinidad and Tobago',), ('Tunisia',), ('Turkey',), ('Tuvalu',), ('Tanzania',), ('Uganda',), ('Ukraine',), ('Upper middle income',), ('Uruguay',), ('United States',), ('Uzbekistan',), ('St. Vincent and the Grenadines',), ('Vietnam',), ('Vanuatu',), ('World',), ('Samoa',), ('Kosovo',), ('Yemen, Rep.',), ('South Africa',), ('Zambia',), ('Zimbabwe',), ('Russian',)]
<class 'list'>
In [78]:
from pyecharts.faker import Faker

from pyecharts.charts import Map
from pyecharts import options as opts
from pyecharts.globals import ChartType, SymbolType

def timeline_map() -> Timeline:
    tl = Timeline()
    for i in range(2010,2017):
        map0 = (
            Map()
            .add(
                "全球人均GDP", (list(zip(list(dfb1.CountryName),list(dfa1["{}".format(i)])))), "world",is_map_symbol_show = False
            )
            .set_global_opts(
                title_opts=opts.TitleOpts(title="".format(i),subtitle="",
                                         subtitle_textstyle_opts=opts.TextStyleOpts(color="red",font_size=16,font_style="italic")),
                visualmap_opts=opts.VisualMapOpts(min_=0, max_=100,series_index=0),
            
            )
        )
        tl.add(map0, "{}".format(i))
    return tl

timeline_map().render_notebook()
Out[78]:

全球人均GDP分析(结合全球青少年怀孕率现状):

  • 以上数据图表显示的是2010年到2016年人均GDP的全球分布轮播图,从地图上的数据我们可以看出全球人均GDP的还是存在较大的差距的,从各大洲的角度来看的话,北美洲和欧洲的人均GDP较高,而非洲各国的人均GDP也是存在较大的差距的,许多南非地区的人均GDP较高,而西非地区的人均GDP较低,然后我还发现了一个很神奇的数据就是Angola的数据,全球人均GDP基本都是呈上升的趋势,的但是Angola的人均GDP却每年都在下降,这是一件很神奇的事情,据我所了解Angola是全球最不发达的国家之一,但是随着经济全球化的影响,Angola的人均GDP竟每年都在下降,但我们很庆幸的是从上一张图表中我们可以看出Angola的青少年怀孕率还是在逐年减少的,我们现在来结合上一张有关全球青少年怀孕率的轮播图来看,我们可以看出全球人均GDP和全球青少年怀孕率大部分是呈负相关的关系,人均GDP高的国家,青少年怀孕率就较低,而相反人均GDP较低的国家,青少年怀孕率就较高。接下来我将抽取8个青少年怀孕率较高的8个国家进行相应的数据分析。
In [79]:
import pandas as pd
df =pd.read_csv("GDPandAFP_max.csv",encoding = 'GBK')
df
Out[79]:
country GDP Adolescent_fertility_rate
0 Angola 409.812942 150.5260
1 Mali 828.613220 169.1270
2 Chad 664.303316 161.0900
3 Niger 375.869490 186.5380
4 Burkina Faso 600.200100 153.1922
5 Central African Republic 823.230000 140.6370
6 Equatorial Guinea 820.302000 169.9012
In [80]:
print(list(df.country))
['Angola', 'Mali', 'Chad', 'Niger', 'Burkina Faso', 'Central African Republic', 'Equatorial Guinea']
In [81]:
print(list(df.GDP))
[409.812942, 828.6132202, 664.3033157000001, 375.8694897, 600.2001, 823.23, 820.302]
In [82]:
print(list(df.Adolescent_fertility_rate))
[150.526, 169.127, 161.09, 186.53799999999998, 153.1922, 140.637, 169.9012]
In [83]:
八国对比双指标数据 = list(zip(list(df.GDP),list(df.Adolescent_fertility_rate)))
print(八国对比双指标数据)
[(409.812942, 150.526), (828.6132202, 169.127), (664.3033157000001, 161.09), (375.8694897, 186.53799999999998), (600.2001, 153.1922), (823.23, 140.637), (820.302, 169.9012)]
In [84]:
八国对比双指标数据 = zip(list(df.GDP),list(df.Adolescent_fertility_rate))
print(八国对比双指标数据)
<zip object at 0x0000015EFF595B48>
In [85]:
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Bar, Grid, Line,Scatter


def grid_vertical() -> Grid:
    bar = (
        Bar()
        .add_xaxis(list(df.country))
        .add_yaxis("青少年怀孕率最高八国GDP",list(df.GDP))
        .set_global_opts(title_opts=opts.TitleOpts(title="青少年怀孕率最高八国GDP"))
    )
    line = (
        Line()
        .add_xaxis(list(df.country))
        .add_yaxis("青少年怀孕率最高八国青少年怀孕率",list(df.Adolescent_fertility_rate))
        .set_global_opts(
            title_opts=opts.TitleOpts(title="青少年怀孕率最高八国青少年怀孕率", pos_top="48%"),
            legend_opts=opts.LegendOpts(pos_top="48%"),
        )
    )

    grid = (
        Grid()
        .add(bar, grid_opts=opts.GridOpts(pos_bottom="60%"))
        .add(line, grid_opts=opts.GridOpts(pos_top="60%"))
    )
    return grid
grid_vertical().render_notebook()
Out[85]:

青少年怀孕率最高的8个国家数据对比图分析与反思:

  • 我抽取了这8个国家的2016年的人均GDP和青少年怀孕率的数据进行了分析比较,这八个国家分别是Angola,Mali, Chad, Niger, Burkina Faso, Central African Republic和Equatorial Guinea,这些国家普遍分布在非洲地区,这些国家的人均GDP相对较低,在世界分区中属于落后国家的行列,而这些国家政府在教育上又投资的多少,在教育方面是否存在一定的缺失,女性在社会上的地位又是处于一个怎样的地位,联合国人口基金会拉美及加勒比区域主任Esteban Caballero认为,少女高怀孕率与信息的缺乏、未能获得全面的性教育及生殖健康服务直接相关,“许多怀孕并非是故意的选择,而是一种结果。减少少女怀孕现象意味着必须掌握有效的避孕方法。”过早的怀孕对少女来说还不只是健康的问题,即使她们顺利生下了孩子,也要面对社会的各种压力。联合国儿童基金会区域主任Marita Perceval指出,许多女孩因为怀孕必须辍学,这对她们完成学业、就业以及参与公共政治生活的能力具有长期影响。“少女母亲更容易受到伤害,贫困和社会的排斥会一再被重复。”此外,许多数据报告还发现,在大多数国家,没有受过教育或只受过小学教育的少女,她们怀孕的可能性比受过中学或高等教育的女孩高4倍;与此同时,在一个国家中,与收入最高的五分之一家庭相比,收入最低的五分之一家庭的女孩成为少女母亲的可能性也要高3至4倍。土著女孩,特别是农村地区的土著女孩,更有可能在很小的年纪就怀孕。接下来我抽取了两个国家在教育投资上的数据分析,这两个国家分别是青少年怀孕率较高的一个国家Mali,一个是青少年怀孕率较低的国家Finland。
In [1]:
import pandas as pd
df =pd.read_csv("min_AFR.csv",encoding = 'GBK',index_col='CountryName')
df
Out[1]:
CountryCode 2014 2015 2016 2017
CountryName
Netherlands NLD 4.1840 4.0520 3.9200 3.788
Finland FIN 6.7790 6.4570 6.1350 5.813
Korea KOR 1.6112 1.5338 1.4564 1.379
Luxembourg LUX 5.7332 5.3978 5.0624 4.727
In [2]:
x轴 = [int(x)for x in df.columns.values[-4:]]
x轴
Out[2]:
[2014, 2015, 2016, 2017]
In [3]:
Netherlands=list(df.loc['Netherlands'].values)[-4:]
Netherlands
Out[3]:
[4.184, 4.052, 3.92, 3.7880000000000003]
In [4]:
Finland=list(df.loc['Finland'].values)[-4:]
Finland
Out[4]:
[6.779, 6.457000000000001, 6.135, 5.813]
In [5]:
Korea=list(df.loc['Korea'].values)[-4:]
Korea
Out[5]:
[1.6112, 1.5338, 1.4564, 1.379]
In [6]:
Luxembourg=list(df.loc['Luxembourg'].values)[-4:]
Luxembourg
Out[6]:
[5.7332, 5.3978, 5.0624, 4.727]
In [7]:
import pandas as pd
dfe = pd.read_csv("education.csv",index_col=0)
dfe.head()
Out[7]:
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 ... 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019
Country Name
Finland 1.08712 1.09401 1.10610 1.09169 1.08613 1.07793 1.09221 1.07399 1.05196 1.04770 ... 1.02248 1.02109 1.02188 1.05432 1.05676 1.05718 1.05761 1.05626 1.06259 NaN
Mali 0.58377 0.58546 0.57273 0.59781 0.61089 0.64674 0.63854 0.63312 0.66575 0.67814 ... 0.80729 0.81824 0.81851 0.82185 0.83934 0.86426 0.83802 0.86822 0.87640 NaN

2 rows × 30 columns

In [8]:
dfe.columns = [int(x) for x in dfe.columns]
dfe.index = ['Finland','Mali']
dfe.head()
Out[8]:
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 ... 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019
Finland 1.08712 1.09401 1.10610 1.09169 1.08613 1.07793 1.09221 1.07399 1.05196 1.04770 ... 1.02248 1.02109 1.02188 1.05432 1.05676 1.05718 1.05761 1.05626 1.06259 NaN
Mali 0.58377 0.58546 0.57273 0.59781 0.61089 0.64674 0.63854 0.63312 0.66575 0.67814 ... 0.80729 0.81824 0.81851 0.82185 0.83934 0.86426 0.83802 0.86822 0.87640 NaN

2 rows × 30 columns

In [9]:
dfe.loc["Finland",:]
Out[9]:
1990    1.08712
1991    1.09401
1992    1.10610
1993    1.09169
1994    1.08613
1995    1.07793
1996    1.09221
1997    1.07399
1998    1.05196
1999    1.04770
2000    1.04842
2001    1.05447
2002    1.05660
2003    1.05271
2004    1.02023
2005    1.02006
2006    1.02063
2007    1.02225
2008    1.02240
2009    1.02357
2010    1.02248
2011    1.02109
2012    1.02188
2013    1.05432
2014    1.05676
2015    1.05718
2016    1.05761
2017    1.05626
2018    1.06259
2019        NaN
Name: Finland, dtype: float64
In [10]:
# 增加标题title,利用Layout做排版
# plotly.offline.init_notebook_mode()
import plotly as py
import plotly.graph_objs as go

Finland = go.Scatter(
    x=[pd.to_datetime('01/01/{y}'.format(y=x), format="%m/%d/%Y") for x in dfe.columns.values],
    y=dfe.loc["Finland",:].values,
    name = "Finland"
)

Mali = go.Scatter(
    x=[pd.to_datetime('01/01/{y}'.format(y=x), format="%m/%d/%Y") for x in dfe.columns.values],
    y=dfe.loc["Mali",:].values,
    name = "Mali"
)

layout = dict(xaxis=dict(rangeselector=dict( buttons=list([
                                                dict(count=1,
                                                     label="1年",
                                                     step="year",
                                                     stepmode="backward"),
                                                dict(count=2,
                                                     label="2年",
                                                     step="year",
                                                     stepmode="backward"),
                                                dict(count=3,
                                                     label="3年",
                                                     step="year",
                                                     stepmode="backward"),
                                                dict(count=4,
                                                     label="4年",
                                                     step="year",
                                                     stepmode="backward"),
                                                dict(step="all")
                                            ])),
                         rangeslider=dict(bgcolor="#70EC57"),
                         title='年份'
                        ),
              yaxis=dict(title='两国教育程度对比图'),
              title="两国教育程度对比图"               
             )

fig = dict(data=[Finland,Mali], layout=layout) 

py.offline.iplot(fig, filename = "输出中文_含时间序列的滑块选择器.html")
#              ^^^这里可以只放数据data,也可以将数据data和排版layout结合,这是典型的面向对象

Finland和Mali教育投入资金分析图:

  • 上图是关于Finland和Mal从1990年到2015年的政府教育投入资金的趋势图,可以看出从1990年开始Finland政府在教育方面的资金投入就比Mali要高出一倍,但是从趋势上看,Mali政府在教育投入上呈上升的趋势,到了2018年已经趋近0.9,而Finland政府在教育资源的投入中一直处于1.1左右的,并没有太大的变动,根据青少年怀孕率的数据图显示Mali的青少年怀孕率也是呈逐年下降的趋势。
In [242]:
import pandas as pd
import csv,os
from pyecharts import options as opts
from pyecharts.globals import ChartType,SymbolType
from pyecharts.charts import Bar,Tab,Line,Map,Timeline,Grid,Scatter,Liquid
In [243]:
import pandas as pd
df =pd.read_csv("max_AFR.csv",encoding = 'GBK',index_col='CountryName')
df
Out[243]:
CountryCode 2014 2015 2016 2017
CountryName
Angola AGO 160.6504 157.2756 153.9008 150.526
Mali MLI 174.9938 173.0382 171.0826 169.127
Chad TCD 171.3680 167.9420 164.5160 161.090
Niger NER 195.0610 192.2200 189.3790 186.538
BurkinaFaso BFA 110.9764 108.7606 106.5448 104.329
CentralAfricaRepublic CAF 134.7086 132.8304 130.9522 129.074
EquatorialGuinea GNQ 162.3144 160.0836 157.8528 155.622
Zambia ZMB 130.0624 126.7456 123.4288 120.112
In [244]:
x轴 = [int(x)for x in df.columns.values[-4:]]
x轴
Out[244]:
[2014, 2015, 2016, 2017]
In [245]:
Angola=list(df.loc['Angola'].values)[-4:]
Angola
Out[245]:
[160.6504, 157.2756, 153.9008, 150.526]
In [246]:
Mali=list(df.loc['Mali'].values)[-4:]
Mali
Out[246]:
[174.9938, 173.0382, 171.0826, 169.127]
In [247]:
Chad=list(df.loc['Chad'].values)[-4:]
Chad
Out[247]:
[171.368, 167.942, 164.516, 161.09]
In [248]:
Niger=list(df.loc['Niger'].values)[-4:]
Niger
Out[248]:
[195.06099999999998, 192.22, 189.37900000000002, 186.53799999999998]
In [249]:
BurkinaFaso=list(df.loc['BurkinaFaso'].values)[-4:]
BurkinaFaso
Out[249]:
[110.9764, 108.7606, 106.5448, 104.329]
In [250]:
CentralAfricaRepublic=list(df.loc['CentralAfricaRepublic'].values)[-4:]
CentralAfricaRepublic
Out[250]:
[134.7086, 132.8304, 130.9522, 129.07399999999998]
In [251]:
EquatorialGuinea=list(df.loc['EquatorialGuinea'].values)[-4:]
EquatorialGuinea
Out[251]:
[162.3144, 160.0836, 157.8528, 155.622]
In [252]:
Zambia=list(df.loc['Zambia'].values)[-4:]
Zambia
Out[252]:
[130.0624, 126.7456, 123.4288, 120.11200000000001]
In [ ]:
 
In [253]:
import pandas as pd
import csv,os
from pyecharts import options as opts
from pyecharts.globals import ChartType,SymbolType
from pyecharts.charts import Bar,Tab,Line,Map,Timeline,Grid,Scatter,Liquid
In [254]:
def timeline_map() -> Timeline:
    tl = Timeline()
    for i in range(2010,2017):
        map0 = (
            Map()
            .add(
                "青少年怀孕率", (list(zip(list(dfa1.CountryName),list(dfa1["{}".format(i)])))), "world",is_map_symbol_show = False
            )
            .set_global_opts(
                title_opts=opts.TitleOpts(title="".format(i),subtitle="",
                                         subtitle_textstyle_opts=opts.TextStyleOpts(color="red",font_size=16,font_style="italic")),
                visualmap_opts=opts.VisualMapOpts(min_=0, max_=100,series_index=0),
            
            )
        )
        tl.add(map0, "{}".format(i))
    return tl

def overlap_line_scatter() -> Bar:
    x = list(['2014', '2015', '2016', '2017'])
    bar = (
        Bar()
        .add_xaxis(x)
        .add_yaxis("Netherlands", Netherlands)
        .add_yaxis("Finland", Finland)
        .add_yaxis("Korea", Korea)
        .add_yaxis("Luxembourg", Luxembourg)
        .set_global_opts(title_opts=opts.TitleOpts(title="青少年怀孕率最低四国数据"))
    )
    line = (
        Line()
        .add_xaxis(x)
        .add_yaxis("Netherlands", Netherlands)
        .add_yaxis("Finland", Finland)
        .add_yaxis("Korea", Korea)
        .add_yaxis("Luxembourg", Luxembourg)
    )
    bar.overlap(line)
    return bar

def data() -> Bar:
    x = list(['2014', '2015', '2016', '2017'])
    bar = (
        Bar()
        .add_xaxis(x)
        .add_yaxis("Angola", Angola)
        .add_yaxis("Mali", Mali)
        .add_yaxis("Chad", Chad)
        .add_yaxis("Niger", Niger)
        .add_yaxis("BurkinaFaso", BurkinaFaso)
        .add_yaxis("CentralAfricaRepublic", CentralAfricaRepublic)
        .add_yaxis("EquatorialGuinea", EquatorialGuinea)
        .add_yaxis("Zambia", Zambia)
        
        .set_global_opts(title_opts=opts.TitleOpts(title="Top8"))
    )

    return bar

tab = Tab()
tab.add(timeline_map(), "2010~2017青少年怀孕率地图")
tab.add(data(), "2014~2017青少年怀孕率最高八个国家数据")
tab.add(overlap_line_scatter(), "最低四国数据图")

tab.render_notebook()
Out[254]:

以上三幅可视化数据图分别是2010年到2017年青少年怀孕率地图,2014年到2017年青少年怀孕率最高的8个国家数据柱状图和2014年到2017年青少年怀孕率最低的4个国家数据柱状图,把这三个图放在一起想让大家知道,每年约有1600万15-19岁的青少年生产,约占全世界所有生产的11%。这些生产中有95%发生在低收入和中等收入国家。中等收入国家青少年的平均生产率是高收入国家的一倍以上,低收入国家的这一比率要高出四倍。在青少年时期发生的生产比例在中国约为2%,拉丁美洲和加勒比为18%,撒哈拉以南非洲要超过50%。在低收入和中等收入国家,约有10%的女童到16岁时就成为母亲,这一比率在撒哈拉以南非洲和中南亚和东南亚地区最高。在15岁之前就开始妊娠的妇女比率在地区之间的差异很大,婚外育儿在许多国家都很常见。与亚洲国家相比,拉丁美洲、加勒比、部分撒哈拉以南非洲和高收入国家的婚外青少年怀孕比率更高。未婚青少年母亲生产更多情况下属于意外,更容易以引产而告终。在15岁之前首次出现性行为的女童中,有10%的人报告曾发生强迫性行为,这就会导致青少年意外妊娠。虽然10–19岁少女占全世界所有生产数的11%,但她们却占到因妊娠和生产而造成的疾病总负担(残疾调整生命年)的23%。在低收入和中等收入国家的所有不安全流产中,有14%属于年龄在15–19岁之间的妇女。每年约有250万名青少年实施不安全流产,与年长妇女相比,女青少年受到并发症的影响更加严重。在拉丁美洲,年龄在16岁以下的女青少年中发生的孕产妇死亡危险比20多岁妇女要高出四倍。所以我们呼吁各国必须要重视青少年怀孕率。

In [ ]: